package com.example.musicplayer

import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.util.Log
import android.widget.Button
import android.widget.ImageView
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.net.toUri
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.fragment.app.FragmentManager
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
import retrofit2.http.Url

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        if (savedInstanceState==null) {
            supportFragmentManager.beginTransaction()
                .replace(R.id.change,MusicRecommendation())
                .commit()
        }
        //设计切换页面的三个按钮音乐推荐页面
        val MusicRecommendationBtn=findViewById<Button>(R.id.MusicRecommendationBtn)
        MusicRecommendationBtn.setOnClickListener {
            val fragmentManager=supportFragmentManager
            val transaction=fragmentManager.beginTransaction().apply {
                replace(R.id.change,MusicRecommendation())
                commit()
            }
        }
        //音乐播放器页面
        val MusicPlayBtn=findViewById<Button>(R.id.MusicPlayBtn)
        MusicPlayBtn.setOnClickListener {
            val fragmentManager=supportFragmentManager
            val transaction=fragmentManager.beginTransaction().apply {
                replace(R.id.change,MusicPlayer())
                commit()
            }
        }
        //音乐列表页面
        val MusicListBtn=findViewById<Button>(R.id.MusicListBtn)
        MusicListBtn.setOnClickListener {
            val fragmentManager=supportFragmentManager
            val transaction=fragmentManager.beginTransaction().apply {
                replace(R.id.change,MusicList())
                commit()
            }
        }

    }
}